import { defineStore } from 'pinia'
import { ref, computed } from 'vue'
import type { LearnBaseQuestionInfo } from '@/api/base/types'

/**
 *学习题库Store
 */
export const useLearnBaseQbTwoStore = defineStore(
  'learn_base_qb_two',
  () => {
    /* 试题列表 */
    const questions = ref<LearnBaseQuestionInfo[]>([])

    /* 设置试题 */
    const setQuestions = (data: LearnBaseQuestionInfo[]) => {
      questions.value = data
    }

    /* 清空试题 */
    const clearQuestions = () => {
      questions.value = []
    }

    return {
      questions,
      setQuestions,
      clearQuestions,
    }
  },
  {
    persist: {
      storage: {
        getItem(key) {
          return uni.getStorageSync(key)
        },
        setItem(key, value) {
          uni.setStorageSync(key, value)
        },
      },
    },
  },
)
